home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / dev / src / wangisrc.lha / wangi / z / oldwp / Menu / ARexx.PAS next >
Pascal/Delphi Source File  |  1994-11-20  |  1KB  |  45 lines

  1. Procedure SendARexxCommand(command, destport : string; am : pAppMessage);
  2.  
  3. VAR
  4.     rxmsg         : pRexxMsg;
  5.     ap, dummyport : pMsgPort;
  6.     dummsg        : pMessage;
  7.     dp            : string;
  8.     
  9. Begin
  10.     dp := destport + #0;
  11.     if (RexxSysBase <> NIL) and (command <> '') and (destport <> '') then begin
  12.         { subsitute args }
  13.         command := PutArgs(command,am);
  14.         { rexx available, command and port reasonably valid }
  15.         dummyport := CreateMsgPort;
  16.         if dummyport <> NIL then begin
  17.             { create an ARexx message }
  18.             rxmsg := CreateRexxMsg(DummyPort,NIL,NIL);
  19.             if rxmsg <> NIL then begin
  20.                 { create an argument string }
  21.                 rxmsg^.rm_Args[0] := CreateArgstring(@command[1],length(command));
  22.                 if rxmsg^.rm_Args[0] <> NIL then begin
  23.                     rxmsg^.rm_Action := RXCOMM|RXFF_NOIO;
  24.                     { make sure port does not disapear }
  25.                     Forbid;
  26.                     { find the destination port }
  27.                     ap := FindPort(@dp[1]);
  28.                     if ap <> NIL then
  29.                         { send the message }
  30.                         PutMsg(ap, pMessage(rxmsg));
  31.                     Permit;
  32.                     if ap <> NIL then begin
  33.                         { wait for message and remove }
  34.                         dummsg := WaitPort(DummyPort);
  35.                         dummsg := GetMsg(DummyPort);
  36.                     end;
  37.                     ClearRexxMsg(rxmsg,1);
  38.                 end;
  39.                 DeleteRexxMsg(rxmsg);
  40.             end;
  41.             DeleteMsgPort(dummyport);
  42.         end;
  43.     end;
  44. end;
  45.